好好学习,天天向上

pythonchallenge.com | Python Challenge 第1关 题解

再接再厉,继续玩吧~

内容

这次的题目是:

题解

好吧,我承认,小小的做了下弊……

anyway, 就是对下面一串长长的字符串移位操作。

你问我怎么移?图告诉我们了呀~k变成m,移了2位;o变成q,移了2位;e变成g,也是移了2位。

ok,我们来写点代码吧~

1
2
3
4
5
6
7
8
9
10
11
s = """g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp. bmgle gr gl zw fylb gq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj."""

res = """"""

for ch in s:
if ch.islower():
res = res + str(chr(97+(ord(ch)+2-97)%26))
else:
res = res + ch

print res

得到res的结果是:i hope you didnt translate it by hand. thats what computers are for. doing it in by hand is inefficient and that's why this text is so long. using string.maketrans() is recommended. now apply on the url.

猜测是要将当前网页的名字,也就是map做移位操作。map >>2 就变成了ocr……

Ok, 开始第二关吧~

请言小午吃个甜筒~~